<%-- 
    Document   : HomePage
    Created on : Oct 25, 2014, 4:07:40 PM
    Author     : user
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="newpackage.ConnectionFactory"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body background="image.jpg">
    <h1> ENSURING PRIVACY AND DATA FRESHNESS OF SHARED DATA IN CLOUD </h1>
    <center>
    <%! boolean checkUser(String user,String password)throws Exception
         {
    Connection con=ConnectionFactory.getConnection();
    Statement select=con.createStatement();  
    String query="Select * from user_details where user_name='"+user+"' and password='"+password+"'";
    ResultSet rs=select.executeQuery(query);
    if(rs.next())
               {
        return true;
               }
     return false;
    }
        %>
<% 
String user_name=request.getParameter("user_name");
String password=request.getParameter("password");
boolean b=checkUser(user_name, password);
if(request.getParameter("user_name")!=null&&request.getParameter("password")!=null)
{
if(request.getParameter("user_name").equals("admin")&&request.getParameter("password").equals("admin"))
{
	session.setAttribute("user_name","admin");
        response.sendRedirect("FileUpload.jsp");

}
else if(user_name.equals("audit")&&password.equals("audit"))
{
    session.setAttribute("user_name","auditor");
     response.sendRedirect("AuditFile.jsp");
}
else if(checkUser(user_name, password))
 {session.setAttribute("user_name",user_name);
     response.sendRedirect("ViewFile.jsp");
}
else
{
    request.setAttribute("message","Username or password must be error");
    request.getRequestDispatcher("/Login.jsp").forward(request, response);
}

}

%>

</center>
</body>
</html>